package com.huawei.appgallery.assistantdock.base.externalaction;

import android.app.Activity;
import android.content.Intent;
import com.huawei.appgallery.assistantdock.base.externalaction.openviewaction.IOpenViewAction;
import com.huawei.appgallery.assistantdock.base.externalaction.openviewaction.OpenViewActionRegistry;
import com.huawei.gamebox.plugin.gameservice.action.IGameServiceAction;
import com.huawei.hwid.core.constants.HwAccountConstants;
import com.huawei.secure.android.common.intent.SafeIntent;
import o.bga;
import o.cjk;
import o.cjm;
import o.Logger;
import o.dof;
import o.dys.a;
import o.fam;
import o.fiu;
import o.fjb;

public class OpenViewAction extends IGameServiceAction {
    public static final String ACTION_OPEN_VIEW = "com.huawei.gamebox.ACTION_OPEN_VIEW";
    private static final String TAG = "OpenViewAction";
    private boolean hasStop = false;
    private boolean isFromBuoy = false;
    private IOpenViewAction openViewAction = null;

    public OpenViewAction(a aVar) {
        super(aVar);
    }

    public void onAction() {
        Logger.ˏ(TAG, "start open view from game service");
        String stringExtra = new SafeIntent(this.callback.getIntent()).getStringExtra("taskId");
        if (dof.ॱ(stringExtra)) {
            Logger.e(TAG, "taskId null");
            this.callback.finish();
            return;
        }
        this.isFromBuoy = bga.ॱ().ˎ(stringExtra);
        Logger.ˏ(TAG, "open view by the task id:" + stringExtra);
        Object ˊ = bga.ॱ().ˊ(stringExtra);
        if (ˊ instanceof Intent) {
            SafeIntent safeIntent = new SafeIntent((Intent) ˊ);
            this.openViewAction = OpenViewActionRegistry.getAction(this.callback, safeIntent.getAction(), safeIntent);
            if (this.openViewAction != null) {
                this.openViewAction.onAction();
            } else {
                this.callback.startActivity((Intent) ˊ);
            }
        } else if (ˊ instanceof cjm) {
            cjk.ˎ().ˋ((Activity) this.callback, (cjm) ˊ);
        } else if (ˊ instanceof fjb) {
            dispatchOpenForumAction((fjb) ˊ);
        } else {
            if (this.isFromBuoy) {
                fam.ॱ().ˋ((Activity) this.callback);
            }
            this.callback.finish();
        }
    }

    public void onResume() {
        if (this.hasStop) {
            if (this.isFromBuoy) {
                fam.ॱ().ˋ((Activity) this.callback);
            }
            if (this.openViewAction == null || this.openViewAction.isFinishOnResume()) {
                this.callback.finish();
            }
        }
    }

    public void onPause() {
        this.hasStop = true;
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        if (this.openViewAction != null) {
            this.openViewAction.onActivityResult(i, i2, intent);
        }
    }

    private void dispatchOpenForumAction(fjb o_fjb) {
        fiu.ˊ().ॱ((Activity) this.callback, o_fjb, new Intent().setFlags(HwAccountConstants.FLAG_TRANSLUCENT_STATUS));
    }
}
